/**
 * @author LKQ
 * @date 2022/2/25 13:53
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public String sortSentence(String s) {
        String[] arr = s.split(" ");
        Map<Integer, String> map = new HashMap<>();
        int max = 0, n = 0;
        for(String a: arr) {
            int length = a.length();
            n =  a.charAt(length - 1) - '1';
            max = Math.max(max, n);
            map.put(n, a.substring(0, length - 1));
        }
        String[] ans = new String[max + 1];
        for(int i = 0; i < max + 1; i++) {
            ans[i] = map.get(i);
        }
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < max + 1; i++) {
            if(i != max) {
                sb.append(ans[i] + " ");
            }else {
                sb.append(ans[i]);
            }
        }
        return sb.toString();
    }
}
